// @auth: yan rui
// @Time: 2024-10-31 10:02:38
// @desc: 用户信息，聊天窗口，点击用户头像进入

import 'package:flutter/material.dart';
import '/components/page/common.dart';
import '/components/user_basic_info.dart';
import '/components/list/route_menu_item.dart';
import '/components/custom/full_center_button.dart';
import '/utils/load_image.dart';
import '/config/base_url.dart';

// 用户信息
class UserInfoPage extends StatelessWidget {
  const UserInfoPage({super.key});

  @override
  Widget build(BuildContext context) {

    double imgSize = 46.0;
    Widget albumsList = Row(
        children: [
          loadImageByUrl('$baseUrl/avatar/tx40.jpg', imgSize, imgSize),
          const SizedBox(width: 6.0),
          loadImageByUrl('$baseUrl/avatar/tx41.jpg', imgSize, imgSize),
          const SizedBox(width: 6.0),
          loadImageByUrl('$baseUrl/avatar/tx42.jpg', imgSize, imgSize),
          const SizedBox(width: 6.0),
          loadImageByUrl('$baseUrl/avatar/tx43.jpg', imgSize, imgSize),
        ]
    );
    Widget albumsList2 = Row(
        children: [
          loadImageByUrl('$baseUrl/avatar/tx30.jpg', imgSize, imgSize),
          const SizedBox(width: 6.0),
          loadImageByUrl('$baseUrl/avatar/tx31.jpg', imgSize, imgSize),
          const SizedBox(width: 6.0),
          loadImageByUrl('$baseUrl/avatar/tx32.jpg', imgSize, imgSize),
          const SizedBox(width: 6.0),
          loadImageByUrl('$baseUrl/avatar/tx33.jpg', imgSize, imgSize),
        ]
    );

    List listData = [
      {
        'title': '朋友圈',
        'hasBottom': false,
        'customCenterWidget': Padding(
          padding: const EdgeInsets.only(left: 20.0),
          child: albumsList
        ),
        'onTap': () {
          Navigator.pushNamed(context, 'FriendsCirclePage');
        }
      },
      {
        'title': '视频号',
        'hasBottom': false,
        'customCenterWidget': Padding(
          padding: const EdgeInsets.only(left: 20.0),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              const Text('前端没钱', style: TextStyle(fontSize: 16),),
              const SizedBox(height: 6),
              albumsList2,
            ],
          ),
        ),
        'onTap': () {
          Navigator.pushNamed(context, 'EmptyPage', arguments: {
            'title': '视频号',
          });
        },
      },
      {
        'title': '更多信息',
        'onTap': () {
          Navigator.pushNamed(context, 'EmptyPage', arguments: {
            'title': '更多信息',
          });
        },
      },
    ];

    return CommonPage(
      title: '',
      appBarBgColor: Colors.white,
      child: Column(
        children: [
          const UserBasicInfoWidget(),
          const SizedBox(height: 10),
          // Column(
          //     children: listData.map((item) => RouteMenuItem(
          //       leftImgPath: item['leftImgPath'],
          //       title: item['title'],
          //       hasBottom: item['hasBottom'] ?? true,
          //       rightText: item['rightText'],
          //       onTap: item['onTap'],
          //     )).toList()
          // ),
          ...listData.map((item) => RouteMenuItem(
            leftImgPath: item['leftImgPath'],
            title: item['title'],
            hasBottom: item['hasBottom'] ?? true,
            rightText: item['rightText'],
            customCenterWidget: item['customCenterWidget'],
            onTap: item['onTap'],
          )),
          FullCenterButton(
            iconName: Icons.messenger_outline,
            text: '发消息',
            onTap: () {
              Navigator.pushNamed(context, 'ChatWindowPage', arguments: {
                'userName': '前端没钱',
              });
            },
          )
        ],
      ),
    );
  }
}